package com.hy.myapp.mapper;

public class ReputationMapperSql extends BaseMapperSql{
	public String getQueryDeadAllSql() {
		StringBuilder sb=new StringBuilder();
		sb.append(" 		select                                                       ");
		sb.append(" 		    a.id,                                                    ");
		sb.append(" 		    a.name,                                                  ");
		sb.append(" 		    a.brief,                                                 ");
		sb.append(" 		    a.deleted,                                               ");
		sb.append(" 		    to_char(a.create_time,'yyyy-mm-dd hh24:mi:ss') as ctime, ");
		sb.append(" 		    b.name as creater                                        ");
		sb.append(" 		from ( select * from mc_reputation where deleted=0 )  a      ");
		sb.append(" 		left join mc_user b                                          ");
		sb.append(" 		on a.create_uid=b.id                                         ");
		sb.append(" 		order by ctime desc                                          ");
		String sql=sb.toString();
		
		return sql;
	}
	
	public String getPagedQueryAliveSql(String keyword,int start,int end) {
		return getPagedSql(getAliveAllSql(keyword),start,end);
	}
	
	/**
	 * 取活着的全部
	 * @return
	 */
	public String getAliveAllSql(String keyword) {
		StringBuilder sb=new StringBuilder();
		sb.append(" 		select                                                       ");
		sb.append(" 		    a.id,                                                    ");
		sb.append(" 		    a.name,                                                  ");
		sb.append(" 		    a.brief,                                                 ");
		sb.append(" 		    a.deleted,                                               ");
		sb.append(" 		    to_char(a.create_time,'yyyy-mm-dd hh24:mi:ss') as ctime, ");
		sb.append(" 		    b.name as creater                                        ");
		sb.append(" 		from ( select * from mc_reputation where deleted=0 and name like '"+keyword+"' )  a      ");
		sb.append(" 		left join mc_user b                                          ");
		sb.append(" 		on a.create_uid=b.id                                         ");
		sb.append(" 		order by ctime desc                                          ");
		String sql=sb.toString();
		
		return sql;
	}
}
